package com.shz.appletsapi.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.social.connect.web.ProviderSignInUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.WebRequest;

import lombok.extern.slf4j.Slf4j;

@RestController
@Slf4j
public class UserController {
	
	@Autowired
	private ProviderSignInUtils providerSignInUtils;

	@RequestMapping("registUser")
	public String registUser(@RequestParam("name")String name,WebRequest request) {
		providerSignInUtils.doPostSignUp(name, request);
		return "注册成功";
	}
	@RequestMapping("me")
	public Object me() {
		Authentication authentication =	SecurityContextHolder.getContext().getAuthentication();
		return authentication;
	}
}
